package com.example.registration.controller;


import com.example.registration.pojo.Indent;
import com.example.registration.service.IndentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: registration
 * @Description: $
 * @Param: $
 * @return: $
 * @Author: xieyongde
 * @Date: 2019-08-19
 */
@Controller
@RequestMapping("/indent")
public class IndentController {
    @Resource
    private IndentService indentService;

    public IndentService getIndentService() {
        return indentService;
    }

    public void setIndentService(IndentService indentService) {
        this.indentService = indentService;
    }
    //查询所有的订单数
    @RequestMapping("/count.htm")
    @ResponseBody
    public Object count() throws Exception {
        return indentService.count();
    }

    //制作分页条
    @RequestMapping("/getPagingCount.htm")
    @ResponseBody
    public Map getPagingCount(String indent_number,Integer hospital_id,String order_time,String see_time) throws Exception {
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("indent_number", indent_number);
        map.put("hospital_id", hospital_id);
        map.put("order_time", order_time);
        map.put("see_time", see_time);
        return indentService.getPagingCount(map);
    }
    //查询所有的订单
    @RequestMapping("/showindent.htm")
    @ResponseBody
    public Object showindent(int PageIndex, int pageSize,String indent_number,Integer hospital_id,String order_time,String see_time) throws Exception {
        HashMap<String, Object> map = new HashMap<String, Object>();
        // 页码转化成sql的下标
        int index = (PageIndex - 1) * pageSize;
        map.put("index", index);
        map.put("pageSize", pageSize);
        map.put("indent_number", indent_number);
        map.put("hospital_id", hospital_id);
        map.put("order_time", order_time);
        map.put("see_time", see_time);
        return indentService.showindent(map);
    }

    @RequestMapping("/comboBox.htm")
    @ResponseBody
    public Map ComboBox() throws Exception {
        return indentService.ComboBox();
    }

    @RequestMapping("/show.htm")
    @ResponseBody
    public Map show(Integer id) throws Exception {
        return indentService.show(id);
    }
}
